﻿using MediatR;
using RBAC.LuFang.API.Application.Command.RoleCommand;
using RBAC.LuFang.Domain;
using RBAC.LuFang.Domin.Services;

namespace RBAC.LuFang.API.Application.CommandHandlers.RoleHandler
{
    //添加用户角色
    public class UserRoleCreateCommandHandlers:IRequestHandler<UserRoleCreateCommand, int>
    {
        private readonly IRoleService _roleSetvice;

        public UserRoleCreateCommandHandlers(IRoleService roleSetvice)
        {
            _roleSetvice = roleSetvice;
        }

        public async Task<int> Handle(UserRoleCreateCommand request, CancellationToken cancellationToken)
        {
            var res = new UserRole();
            var rid = res.RoleId = request.rid;
            return await _roleSetvice.AddUserRole(rid, request.uid);
        }
    }
}
